#include "StringConvert.h"
#include <stdio.h>

float	StringConvert::stringToFloat(const std::string& str)
{
	float val = 0;
	sscanf_s(str.c_str(), " %g", &val);

	return val;
}

unsigned int StringConvert::stringToUint(const std::string& str)
{
	unsigned int val = 0;
	sscanf_s(str.c_str(), " %u", &val);

	return val;
}

int		StringConvert::stringToInt(const std::string& str)
{
	int val = 0;
	sscanf_s(str.c_str(), " %d", &val);

	return val;
}

bool	StringConvert::stringToBool(const std::string& str)
{
	if ((str == "True") || (str == "true"))
	{
		return true;
	}
	else
	{
		return false;
	}
}

std::string	StringConvert::floatToString(float val)
{
	char buff[64];
	_snprintf_s(buff, sizeof(buff), "%g", val);

	return std::string(buff);
}

std::string	StringConvert::uintToString(unsigned int val)
{
	char buff[64];
	_snprintf_s(buff, sizeof (buff), "%u", val);

	return std::string(buff);
}

std::string	StringConvert::intToString(int val)
{
	char buff[64];
	_snprintf_s(buff, sizeof (buff), "%d", val);

	return std::string(buff);
}

std::string	StringConvert::boolToString(bool val)
{
	if (val)
	{
		return std::string("True");
	}
	else
	{
		return std::string ("False");
	}
}

